import time
def bubble_sort(gas):
    swapped = True
    while swapped:
        swapped = False
    for j in range(0,len(gas)):
        for i in range (0,len(gas) -1 - j):
            if int(gas[i]) < int(gas[i+1]):
                gas[i],gas[i+1] = gas[i+1],gas[i]
                swapped = True
    return gas
x1 = open('m1_sorted.txt')
x2 = open('m2_reverse.txt')
x3 = open('m3_shuffle.txt')
array1 = x1.readlines()
ts = time.time()
g = bubble_sort(array1)
tf = time.time()
print(round((tf - ts)) * 1000, 'миллисекунд')
array2 = x2.readlines()
ts = time.time()
g = bubble_sort(array2)
tf = time.time()
print(round((tf - ts)) * 1000, 'миллисекунд')
array3 = x3.readlines()
ts = time.time()
g = bubble_sort(array3)
tf = time.time()
print(round((tf - ts)) * 1000, 'миллисекунд')
'''
for i in array2:
    print(i,end = '') '''
    

